/*
Created		9/10/2011
Modified		9/10/2011
Project		
Model			
Company		
Author		
Version		
Database		MS SQL 2005 
*/


Create table [Estudiantes]
(
	[idEstudiantes] Integer Identity NOT NULL,
	[Nombre] Varchar(45) NULL,
	[Apellido] Varchar(45) NULL,
	[Direccion] Varchar(150) NULL,
Primary Key ([idEstudiantes])
) 
go

Create table [Libros]
(
	[idLibros] Integer Identity NOT NULL,
	[Titulo] Varchar(100) NULL,
	[FechaPublicacion] Datetime NULL,
	[Editorial] Varchar(100) NULL,
Primary Key ([idLibros])
) 
go

Create table [Autores]
(
	[idAutores] Integer Identity NOT NULL,
	[Nombre] Varchar(45) NULL,
	[Apellido] Varchar(45) NULL,
	[Direccion] Varchar(200) NULL,
	[Nacionalidad] Varchar(45) NULL,
Primary Key ([idAutores])
) 
go

Create table [AutoresLibros]
(
	[idAutores] Integer NOT NULL,
	[idLibros] Integer NOT NULL,
Primary Key ([idAutores],[idLibros])
) 
go

Create table [EstudiantesLibros]
(
	[idEstudiantes] Integer NOT NULL,
	[idLibros] Integer NOT NULL,
Primary Key ([idEstudiantes],[idLibros])
) 
go


Alter table [EstudiantesLibros] add  foreign key([idEstudiantes]) references [Estudiantes] ([idEstudiantes])  on update no action on delete no action 
go
Alter table [AutoresLibros] add  foreign key([idLibros]) references [Libros] ([idLibros])  on update no action on delete no action 
go
Alter table [EstudiantesLibros] add  foreign key([idLibros]) references [Libros] ([idLibros])  on update no action on delete no action 
go
Alter table [AutoresLibros] add  foreign key([idAutores]) references [Autores] ([idAutores])  on update no action on delete no action 
go


Set quoted_identifier on
go


Set quoted_identifier off
go


